package priv.happy.mealpickpro.emum;

/**
 * @Author: HAPPY
 * @Project_name: mealPickPro
 * @Package_name: priv.happy.mealpickpro.emum
 * @Date: 10/15/2023 1:52 AM
 * @Description:
 */
public enum SystemStatusCode {
    SUCCESS(200, "成功"),
    BAD_REQUEST(400, "无效请求"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源未找到"),
    INTERNAL_SERVER_ERROR(500, "内部服务器错误"),
    SERVICE_UNAVAILABLE(503, "服务不可用");

    private final int code;
    private final String message;

    SystemStatusCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static SystemStatusCode fromCode(int code) {
        for (SystemStatusCode statusCode : values()) {
            if (statusCode.code == code) {
                return statusCode;
            }
        }
        throw new IllegalArgumentException("无效的SystemStatusCode代码：" + code);
    }
}
